<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <h2>百度注册</h2>
        <p>
            <label for="userName">
                用户名：<input id="userName" type="text">
            </label>
        </p>
        <p>
            <label for="iphoneNumber">
                电话号码：<input id="iphoneNumber" type="text">
            </label>
        </p>
        <p>
            <label for="passWord">
                密码：<input id="passWord" type="password">
            </label>
        </p>

        <button>注册</button>
    </div>

    <script>
        var userName = document.getElementById('userName')
        var iphoneNumber = document.getElementById('iphoneNumber')
        var passWord = document.getElementById('passWord')
        var input = document.getElementsByTagName('input')
        var userReg = /^[a-zA-Z]{14}$|[\u4e00-\u9fa5]{7}/
        var iphoneReg = /^1[356789]\d{9}$/
        var passWordReg = /^[0-9a-zA-Z,\.]{8,14}$/

        for (var i = 0; i < input.length; i++) {
            input[0].onblur = function () {
                if (!userReg.test(userName.value)) {
                    alert('请输入14个英文字母或者7个中文')
                }
            }
            input[1].onblur = function () {
                if (!iphoneReg.test(iphoneNumber.value)) {
                    alert('请输入正确电话号码')
                }
            }
            input[2].onblur = function () {
                if (!passWordReg.test(passWord.value)) {
                    alert('请输入由数字，字母，标点标点符号组成的密码8-14位')
                }
            }
        }
    </script>
</body>

</html>